import { MonoColour } from '@railmapgen/rmg-palette-resources';
import { describe, expect, it } from 'vitest';
import { CityCode } from '../../../constants/constants';
import { InterchangeInfo } from '../../panels/details/interchange-field';
import { LINE_WIDTH, R, makeStationPath } from './mtr';

const INT: InterchangeInfo = [CityCode.Shanghai, 'sh1', '#E4002B', MonoColour.white, '', ''];

describe('MTR', () => {
    it('0 interchange', () => {
        const path = makeStationPath(R, LINE_WIDTH, []);
        expect(path).toBe(
            'M -5,0 A 5,5,0,0,1,-2.5,-4.330127018922194 A 5,5,0,0,1,2.5,-4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-5,0 Z'
        );
    });
    it('1 interchange', () => {
        const path = makeStationPath(R, LINE_WIDTH, [INT]);
        expect(path).toBe(
            'M -5,0 A 5,5,0,0,1,-2.5,-4.330127018922194 A 5,5,0,0,1,2.5,-4.330127018922194 A 5,5,0,0,1,7.5,-4.330127018922194 A 5,5,0,0,1,2.5,4.330127018922194 A 5,5,0,0,1,2.5,4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-5,0 Z'
        );
    });
    it('2 interchanges', () => {
        const path = makeStationPath(R, LINE_WIDTH, [INT, INT]);
        expect(path).toBe(
            'M -5,0 A 5,5,0,0,1,-2.5,-4.330127018922194 A 5,5,0,0,1,2.5,-4.330127018922194 A 5,5,0,0,1,7.5,-4.330127018922194 A 5,5,0,0,1,7.5,4.330127018922194 A 5,5,0,0,1,2.5,4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-5,0 Z'
        );
    });
    it('3 interchanges', () => {
        const path = makeStationPath(R, LINE_WIDTH, [INT, INT, INT]);
        expect(path).toBe(
            'M -5,0 A 5,5,0,0,1,-2.5,-4.330127018922194 A 5,5,0,0,1,2.5,-4.330127018922194 A 5,5,0,0,1,7.5,-4.330127018922194 A 5,5,0,0,1,12.5,-4.330127018922194 A 5,5,0,0,1,12.5,4.330127018922194 A 5,5,0,0,1,7.5,4.330127018922194 A 5,5,0,0,1,2.5,4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-5,0 Z'
        );
    });
    it('10 interchanges', () => {
        const path = makeStationPath(
            R,
            LINE_WIDTH,
            Array.from({ length: 10 }).map(_ => INT)
        );
        expect(path).toBe(
            'M -5,0 A 5,5,0,0,1,-2.5,-4.330127018922194 A 5,5,0,0,1,2.5,-4.330127018922194 A 5,5,0,0,1,7.5,-4.330127018922194 A 5,5,0,0,1,12.5,-4.330127018922194 A 5,5,0,0,1,17.5,-4.330127018922194 A 5,5,0,0,1,22.5,-4.330127018922194 A 5,5,0,0,1,27.5,-4.330127018922194 A 5,5,0,0,1,32.5,-4.330127018922194 A 5,5,0,0,1,37.5,-4.330127018922194 A 5,5,0,0,1,42.5,-4.330127018922194 A 5,5,0,0,1,47.5,-4.330127018922194 A 5,5,0,0,1,47.5,4.330127018922194 A 5,5,0,0,1,42.5,4.330127018922194 A 5,5,0,0,1,37.5,4.330127018922194 A 5,5,0,0,1,32.5,4.330127018922194 A 5,5,0,0,1,27.5,4.330127018922194 A 5,5,0,0,1,22.5,4.330127018922194 A 5,5,0,0,1,17.5,4.330127018922194 A 5,5,0,0,1,12.5,4.330127018922194 A 5,5,0,0,1,7.5,4.330127018922194 A 5,5,0,0,1,2.5,4.330127018922194 A 5,5,0,0,1,-2.5,4.330127018922194 A 5,5,0,0,1,-5,0 Z'
        );
    });
});
